//
//  ADJgSDKNativeCustomEvent.m
//  AnyThinkSDKDemo
//
//  Created by 刘娟 on 2024/9/25.
//  Copyright © 2024 抽筋的灯. All rights reserved.
//

#import "ADJgSDKNativeCustomEvent.h"
#import <ADJgKit/UIFont+ADJgKit.h>
#import <ADJgKit/UIColor+ADJgKit.h>

@interface ADJgSDKNativeCustomEvent()

@property (nonatomic ,assign) CGSize size;
@end

@implementation ADJgSDKNativeCustomEvent
-(void)loadNativeWithPosId:(NSString *)posId Count:(int)count size:(CGSize)size{
    self.size = size;
    self.nativeAdContainer = [[ADJgSDKNativeAdContainer alloc] initPosId:posId delegate:self size:size];
    [self.nativeAdContainer loadNativeAdWithCount:count];
}

/**
 信息流广告请求成功

 @param nativeAd 广告实例
 @param adViewArray 广告模板集合
 */
//- (void)adjg_nativeAdSucessToLoad:(ADJgSDKNativeAd *)nativeAd
//                      adViewArray:(NSArray<__kindof UIView<ADJgAdapterNativeAdViewDelegate> *> *)adViewArray{
//    if (adViewArray.count) {
//        NSMutableArray<NSDictionary*>* assets = [NSMutableArray<NSDictionary*> array];
//        [adViewArray enumerateObjectsUsingBlock:^(__kindof UIView<ADJgAdapterNativeAdViewDelegate> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//            NSMutableDictionary *asset = [NSMutableDictionary dictionary];
//            UIView<ADJgAdapterNativeAdViewDelegate> *expressView = obj;
//            if (expressView.renderType == ADJgAdapterRenderTypeNative) {
//                //自渲染信息流
//                [self setUpUnifiedTopImageNativeAdView:expressView];
//            }
//            [expressView adjg_registViews:@[expressView]];
//            asset[kATAdAssetsCustomEventKey] = self;
//            asset[kATAdAssetsCustomObjectKey] = obj;
//            asset[@"nativeexpress_manager"] = self.nativeAdContainer;
//            self.nativeAdContainer.controller = [UIApplication sharedApplication].keyWindow.rootViewController;
//            asset[kATNativeADAssetsNativeExpressAdViewWidthKey] = [NSString stringWithFormat:@"%lf",expressView.frame.size.width];
//            asset[kATNativeADAssetsNativeExpressAdViewHeightKey] = [NSString stringWithFormat:@"%lf",expressView.frame.size.height];
//            if (expressView.renderType == ADJgAdapterRenderTypeExpress) {
//                asset[kATNativeADAssetsIsExpressAdKey] = @"1";
//            }
//            [assets addObject:asset];
//        }];
//        [self trackNativeAdLoaded:assets];
//        self.requestCompletionBlock(assets, nil);
//    }
//}
//
///**
// 信息流广告请求失败
//
// @param nativeAd 广告实例
// @param errorModel 请求错误描述
// */
//- (void)adjg_nativeAdFailToLoad:(ADJgSDKNativeAd *)nativeAd
//                     errorModel:(ADJgAdapterErrorDefine *)errorModel{
//    [self trackNativeAdLoadFailed:nil];
//}

/**
 信息流广告渲染成功

 @param adView 广告视图
 */
- (void)adjg_nativeAdViewRenderOrRegistSuccess:(UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    
}

/**
 信息流广告渲染失败

 @param adView 广告视图
 */
- (void)adjg_nativeAdViewRenderOrRegistFail:(UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    
}

/**
 信息流广告被点击

 @param nativeAd 广告模板
 */
- (void)adjg_nativeAdClicked:(ADJgSDKNativeAd *)nativeAd
                      adView:(__kindof UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    [self trackNativeAdClick];
}

/**
 信息流广告被关闭
 
 @param nativeAd 广告模板
 */
- (void)adjg_nativeAdClose:(ADJgSDKNativeAd *)nativeAd
                    adView:(__kindof UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    [adView removeFromSuperview];
    [self trackNativeAdClosed];
}

/**
 信息流广告被展示
 
 @param nativeAd 广告实例
 */
- (void)adjg_nativeAdExposure:(ADJgSDKNativeAd *)nativeAd
                       adView:(__kindof UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    [self trackNativeAdImpression];
}

/**
 信息流广告落地页被关闭
 
 @param nativeAd 广告实例
 */
- (void)adjg_nativeAdCloseLandingPage:(ADJgSDKNativeAd *)nativeAd
                               adView:(__kindof UIView<ADJgAdapterNativeAdViewDelegate> *)adView{
    
}

/**
 视频类型信息流广告player 播放状态更新回调
 
 @param nativeAd 广告实例
 */
- (void)adjg_nativeAd:(ADJgSDKNativeAd *)nativeAd
               adView:(__kindof UIView<ADJgAdapterNativeAdViewDelegate> *)adView playerStatusChanged:(ADJgAdapterNativeMediaPlayerStatus)status{
    
}


- (NSString *)networkUnitId {
    return self.serverInfo[@"slot_id"];
}

@end
